Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(action_manager): Action Manager module integration #184

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

TsXor
Copy link

@TsXor TsXor commented Sep 4, 2022

Integrates https://github.com/TsXor/photoshop-ActionManager-python with minimum modification to main tree.
There's a problem: it seems that the generated code reference is not enough to document my submodule. So what should I do to add more document? By posting it in gist and attach a hyperlink?

…mmunication and completes functions in photoshop js reference

Signed-off-by: TsXor <[email protected]>
@TsXor TsXor force-pushed the action_manager_module_integration branch from 92899c8 to 4461d91 Compare September 4, 2022 16:12
@TsXor
Copy link
Author

TsXor commented Sep 7, 2022

welp I've corrected using flake8, but I don't know what else linter hound is using...

I did poetry run pip install flake8-black and ran flake8 again, but still no more error...

@TsXor TsXor force-pushed the action_manager_module_integration branch from fe848d5 to 50c6ff3 Compare September 7, 2022 11:34
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

@TsXor TsXor force-pushed the action_manager_module_integration branch from ed6bb7e to c004a59 Compare September 7, 2022 12:04
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

@TsXor TsXor force-pushed the action_manager_module_integration branch from c004a59 to 09680e9 Compare September 7, 2022 12:10
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

@TsXor TsXor force-pushed the action_manager_module_integration branch from 09680e9 to 97d51a8 Compare September 7, 2022 12:15
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

@TsXor TsXor force-pushed the action_manager_module_integration branch from 97d51a8 to 8fb9d18 Compare September 7, 2022 12:19
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

@TsXor TsXor force-pushed the action_manager_module_integration branch from 8fb9d18 to f648c6b Compare September 7, 2022 12:29
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

@TsXor TsXor force-pushed the action_manager_module_integration branch from f648c6b to f60b236 Compare September 7, 2022 12:51
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

"pyflakes" failed during execution due to "'FlakesChecker' object has no attr...
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details

@TsXor TsXor marked this pull request as draft September 8, 2022 08:51
@TsXor TsXor force-pushed the action_manager_module_integration branch from 5ecb5ab to 405f8dd Compare September 8, 2022 09:26
@TsXor TsXor marked this pull request as ready for review September 8, 2022 09:27
@TsXor TsXor force-pushed the action_manager_module_integration branch from d575363 to 3e35274 Compare September 8, 2022 13:52
@TsXor TsXor changed the title Action Manager module integration feat(action_manager): Action Manager module integration Sep 8, 2022
I may have to correct something about Action Manager and its classes: ActionDescriptor, ActionList, ActionReference. Action Manager is NOT something to describe your action palette. Action Manager actually enables low-level access into photoshop, and all things in this repo can actually be rewritten in Action Manager. You can consider an ActionDescriptor as dict, ActionList as array, ActionReference as filters for searching. So we should NOT set an INSTANCE of ActionDescriptor as an attribute of a Session and instead we should set the ActionDescriptor CLASS (the same for ActionList, ActionReference).

Signed-off-by: TsXor <[email protected]>
desc_value_types and ref_form_types defines classes which describes AM things and utils contains a shortcut for id conversion.

Nothing breaking. All AM functions are still available.

My submodule uses relative importing because absolute importing causes bigger possibility in path typos.

Signed-off-by: TsXor <[email protected]>
For example, I advice to do 'import photoshop.api.action_manager as am'. Then jprint(prefix='am') should be helpful.

Signed-off-by: TsXor <[email protected]>
… use of my submodule

In fact, why use those ****s born by ScriptListener Plug-in which is totally unreadable?

Signed-off-by: TsXor <[email protected]>
change patching to (try eval + except), and now run black -l 80 to avoid hound warning

There will be lots of violations in hound's eye which I cannot find out locally because hound's linter is not up to date. I will have to do some shattered commits, and for these commits, I will name them hop (hound oriented programming).

Signed-off-by: TsXor <[email protected]>
@TsXor TsXor force-pushed the action_manager_module_integration branch from 3e35274 to 04e9362 Compare September 8, 2022 15:58
@TsXor
Copy link
Author

TsXor commented Sep 9, 2022

https://gist.github.com/TsXor/62a46f8f2846261bba7db1cc7ff02711

Just like Action Manager, I think a HowTo is more useful for this submodule.

@TsXor
Copy link
Author

TsXor commented Sep 10, 2022

The import error is because the server used for importing does not have photoshop installed.

This is fine for testing import. This module doesn't actaully need to do com binding on import because all these classes that inherited Photoshop in _core.py is only defined but not initialized before users of this module do anything.

However, utils.py in my submodule breaks this because it initializes a ps.Application instance on importing for typeid conversion. This will not cause error on real situations, but will make it fail the import test.

This can be tackled by not initializing an app on import and trigger the initialization when any of these functions that need an app is executed.

…ded instead of do it on import to pass import test. 2. Warns user when typeID collision happens. (And id2str will try to avoid giving user string that will cause collision.)

typeID collision happens when a stringID and a charID share the same name. For example, charID 'From' -> stringID 'from' and charID 'from' -> stringID 'originalAddressAttr', so 'from' is a string that will cause collision. After scanning the cpp header "PITerminology.h" and "PIStringTerminology.h", I found 3 such strings and hardcoded them into utils.py. str2id() will not automatically correct user when user gives a collision string (because no one knows what he want it to be a stringID or an charID!), but will regard that string as stringID and throw a warning. Users can follow that warning's guide to fix error and suppress that warning.

Signed-off-by: TsXor <[email protected]>
@TsXor TsXor force-pushed the action_manager_module_integration branch from 53eeb27 to 2712d1c Compare September 10, 2022 13:43
@TsXor
Copy link
Author

TsXor commented Sep 10, 2022

You can get typeID collision detector at gist.
It was first designed to save all the typeID mappings into pickles and free str2id() from initializing an app, but that will bring extra task on photoshop version checking, so I developed the current str2id().
Collision record doesn't need versioning because it is small, therefore have very little possibility to be not backward-compatible.

@TsXor
Copy link
Author

TsXor commented Sep 10, 2022

Something more about charID:
charID can be converted to typeID without photoshop app, for how to do this, see str2hash and hash2str in utils.py.
You may think photoshop api can throw an error when you try to convert a non-existing charID, but the fact is that it cannot.

@TsXor TsXor force-pushed the action_manager_module_integration branch from 232ea04 to 387387f Compare September 12, 2022 05:26
@TsXor TsXor force-pushed the action_manager_module_integration branch from 1a6ffd6 to f77694b Compare December 3, 2022 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants